package room_event

import (
	"longmen/server/internal/rpc/tencentim/chat"
	"longmen/server/internal/rpc/tencentim/utils"
	"longmen/server/pkg/common/helper/timehelper"
	"longmen/server/pkg/db/mysql/db_live"
	pb "longmen/server/pkg/protobuf"
	"time"
)

/*
单聊消息
*/
func handlingBannedStatusMessage(user *chat.ClientUser, b []byte) (ret *pb.CallbackResp, err error) {
	oBanned, err := db_live.GetLiveRoomBanneduserParam(map[string]interface{}{"uid": user.UserId, "anchorid": user.RoomId})

	ret = &pb.CallbackResp{}
	ret.ErrorCode = 0
	sMsg := ""
	if oBanned.Id != 0 && oBanned.BanTime > time.Now().Unix() { //有记录，且还在禁言时间中
		sMsg = "被禁言" + timehelper.Time2Msg(oBanned.BanTime-time.Now().Unix())
		if len(oBanned.Reason) > 0 {
			sMsg = sMsg + ",原因:" + oBanned.Reason
		}
	}
	return utils.CallbackOkResp(sMsg), nil
}
